<template>
  <div class="app-container">
    <el-dialog :title="title" :visible.sync="open" width="1080px" append-to-body v-drag-fullscreen>
    <el-table v-loading="loading" :data="requireRecordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="客户名称" align="center" prop="customName" />
      <el-table-column label="手机号码" align="center" prop="cellPhoneNumber" />
      <el-table-column label="房间名称" align="center" >
        <template slot-scope="scope">
          <span>{{scope.row.communityName}}/{{scope.row.unitName}}/{{scope.row.roomName}} </span>
        </template>
      </el-table-column>
      <el-table-column label="催缴内容" align="center" prop="requireContent" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-html="scope.row.requireContent"></span>
        </template>
      </el-table-column>
      <el-table-column label="催缴时间" align="center" prop="requireTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.requireTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" >
        <template slot-scope="scope">
          {{ dict.label.require_record_status[scope.row.status] }}
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-dialog>
  </div>
</template>

<script>

  import { listMixin } from "@/utils/mixins/listMixin";
  import { listRequireRecord, exportRequireRecord } from "@/api/payfee/requireRecord";

  export default {
    name: "RequireRecord",
    mixins:[ listMixin ],
    dicts: [   'require_record_status',   ],
    data() {
      return {
        // 催缴记录表格数据
        requireRecordList: [],
        open:false,
        title:"",
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          requireId: null,
          customId: null,
          roomId: null,
          requireContent: null,
          requireTime: null,
          status: null
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      show(option){
        this.loading = true;
        this.queryParams.requireId=option.requireId ||-1
        this.queryParams.status=option.status;
        listRequireRecord(this.queryParams).then(response => {
          this.requireRecordList = response.rows;
          this.total = response.total;
          this.loading = false;
          this.open=true;
          if (option.status=='10'){
            this.title="发送详情(成功)"
          }else if (option.status=='20'){
            this.title="发送详情(失败)"
          }
        });
      },
      /** 查询催缴记录列表 */
      getList() {
        this.loading = true;
        listRequireRecord(this.queryParams).then(response => {
          this.requireRecordList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有催缴记录数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportRequireRecord(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
      }
    }
  };
</script>
